package com.martin.lib_base.ui.screen

import androidx.compose.runtime.Stable
import androidx.compose.ui.geometry.RoundRect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.toRect
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import dev.utils.app.SizeUtils

/**
 * @author：孟凡华
 * @date：2023/7/13
 * @desc：
 */
@Stable
fun getRoundedShape(radius: Float): Shape {
    return object : Shape {
        override fun createOutline(
            size: Size,
            layoutDirection: LayoutDirection,
            density: Density
        ): Outline {
            return Outline.Rounded(
                RoundRect(
                    size.toRect(),
                    radiusX = SizeUtils.dp2px(radius).toFloat(),
                    radiusY = SizeUtils.dp2px(radius).toFloat()
                )
            )
        }
    }
}